home *** CD-ROM | disk | FTP | other *** search
- onClipEvent(load){
- function init()
- {
- i = 1;
- while(i <= 9)
- {
- eval("_root.icon_" + i).sweet_num.gotoAndStop(i);
- if(i == 1)
- {
- rndSweetType = 1 + Math.floor(Math.random() * 9);
- sweetRack[i - 1][0] = rndSweetType;
- eval("_root.icon_" + i).sweet_icon.gotoAndStop(rndSweetType);
- eval("_root.area_" + i).gotoAndStop(rndSweetType);
- }
- else
- {
- sweetFound = false;
- rndSweetType = 1 + Math.floor(Math.random() * 9);
- x = 1;
- while(x <= 9)
- {
- if(sweetRack[x - 1][0] == rndSweetType)
- {
- sweetFound = true;
- }
- x++;
- }
- while(sweetFound)
- {
- sweetFound = false;
- rndSweetType = 1 + Math.floor(Math.random() * 9);
- x = 1;
- while(x <= 9)
- {
- if(sweetRack[x - 1][0] == rndSweetType)
- {
- sweetFound = true;
- }
- x++;
- }
- }
- sweetRack[i - 1][0] = rndSweetType;
- eval("_root.icon_" + i).sweet_icon.gotoAndStop(rndSweetType);
- eval("_root.area_" + i).gotoAndStop(rndSweetType);
- }
- i++;
- }
- trace(sweetRack);
- }
- function getSweetbagValue()
- {
- emptyTotal = 0;
- i = 0;
- while(i <= 8)
- {
- emptyTotal += sweetRack[i][1];
- i++;
- }
- if(emptyTotal != 900)
- {
- percentFull = Math.floor((900 - emptyTotal) / 900 * 100);
- }
- else
- {
- percentFull = 0;
- }
- rackValue = 0;
- if(percentFull > 0 && percentFull < 25)
- {
- rackValue = 125;
- }
- else if(percentFull >= 25 && percentFull < 50)
- {
- rackValue = 250;
- }
- else if(percentFull >= 50 && percentFull < 80)
- {
- rackValue = 375;
- }
- else if(percentFull >= 80)
- {
- rackValue = 500;
- }
- return rackValue;
- }
- function rackStatus()
- {
- emptyTotal = 0;
- i = 0;
- while(i <= 8)
- {
- emptyTotal += sweetRack[i][1];
- i++;
- }
- if(emptyTotal != 900)
- {
- rack_status = "full";
- }
- else
- {
- rack_status = "empty";
- }
- return rack_status;
- }
- fps = 10;
- timer = fps * 2;
- numSweets = 9;
- sweetRack = new Array([0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]);
- init();
- }
-